package com.zjuh.qss.biz.dao.impl;

import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;

import wint.lang.utils.MapUtil;

import com.zjuh.qss.biz.dao.UserDAO;
import com.zjuh.qss.biz.domain.UserDO;

public class SimpleUserDAO implements UserDAO {

	private Map<String, UserDO> users = MapUtil.newHashMap();
	
	private AtomicInteger idGenenator = new AtomicInteger(1);
	
	public SimpleUserDAO() {
		addUser("hsl", "hsl12345");
	}
	
	public void addUser(String name, String password) {
		UserDO user = new UserDO();
		user.setId(idGenenator.getAndIncrement());
		user.setName(name);
		user.setPassword(password);
		users.put(user.getName(), user);
	}
	
	@Override
	public int create(UserDO userDO) {
		userDO.setId(idGenenator.getAndIncrement());
		users.put(userDO.getName(), userDO);
		return userDO.getId();
	}

	@Override
	public void delete(int id) {

	}

	@Override
	public UserDO queryById(int id) {
		return null;
	}

	@Override
	public UserDO queryByName(String name) {
		return users.get(name);
	}

	@Override
	public void update(UserDO userDO) {

	}

}
